﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;
using System.Text.RegularExpressions;

namespace Logic
{
    public static class Extentions
    {
        public static String ToJson(this Object obj)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            return serializer.Serialize(obj);
        }

        public static String Spacify(this String str)
        {
            return Regex.Replace(str, "((?<=[a-zA-Z])[A-Z])", " $1").Replace("_", " ");
        }

        public static String[] Spacify(this IEnumerable<Object> strings)
        {
            return strings.Select(s => s.ToString().Spacify()).ToArray();
        }
    }
}
